Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submitter fetches pending transactions independently per chain #2376

Merged
merged 6 commits into from
Mar 29, 2024

Conversation

dwasse
Copy link
Collaborator

@dwasse dwasse commented Mar 27, 2024

Description
Addresses issue where the GetTXS() query for pending transactions enforces inter-chain limit instead of intra-chain limit. Instead of introducing an overly complex raw SQL query, we add a GetChainIDsByStatus() helper to the submitter db and get transactions with individual queries per chain.

Summary by CodeRabbit

  • New Features
    • Enhanced data querying capabilities by introducing a function to retrieve chain IDs based on specific criteria.
  • Tests
    • Ensured reliability and robustness by adding comprehensive tests for the new chain ID retrieval functionality.
  • Refactor
    • Improved code structure and efficiency for fetching and processing pending transactions.

@dwasse dwasse requested a review from trajan0x as a code owner March 27, 2024 20:49
Copy link
Contributor

coderabbitai bot commented Mar 27, 2024

Walkthrough

The recent updates focus on enhancing chain ID management in Ethergo by introducing the GetChainIDsByStatus method across components. These changes, alongside import adjustments and code reorganization, aim to streamline the handling of pending transactions.

Changes

File Path Summary
.../db/mocks/service.go
.../db/service.go
.../db/txdb/store.go
Added GetChainIDsByStatus function to retrieve chain IDs by status. Included math/big import.
.../db_test.go Added test for GetChainIDsByStatus function.
.../submitter/queue.go Imported additional packages, restructured code for fetching and processing pending transactions.

"In the realm of code, where logic plays,
A rabbit hopped, through the Ethergo maze.
🐰 With a leap and a bound, it found a way,
To fetch chain IDs, both night and day.
🌟 'Twas a change so bright, in the ledger's haze,
Guiding transactions, through the blockchain's craze."

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

@github-actions github-actions bot added go Pull requests that update Go code size/s labels Mar 27, 2024
Copy link

cloudflare-workers-and-pages bot commented Mar 27, 2024

Deploying sanguine-fe with  Cloudflare Pages  Cloudflare Pages

Latest commit: cbe85ea
Status: ✅  Deploy successful!
Preview URL: https://1419c050.sanguine-fe.pages.dev
Branch Preview URL: https://feat-submitter-bump-fairness.sanguine-fe.pages.dev

View logs

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 490d295 and 97c0e6f.
Files selected for processing (5)
  • ethergo/submitter/db/mocks/service.go (1 hunks)
  • ethergo/submitter/db/service.go (2 hunks)
  • ethergo/submitter/db/txdb/store.go (3 hunks)
  • ethergo/submitter/db_test.go (1 hunks)
  • ethergo/submitter/queue.go (3 hunks)
Additional comments: 10
ethergo/submitter/db/service.go (2)
  • 8-8: The addition of the math/big package is appropriate given the use of *big.Int in the new method GetChainIDsByStatus.
  • 39-40: The new method GetChainIDsByStatus is a significant addition. It's crucial to ensure that the method's implementation in the corresponding implementation files (e.g., store.go) correctly handles the logic for fetching distinct chain IDs based on the given address and status. This method enhances the granularity of transaction fetching, aligning with the PR's objectives.
ethergo/submitter/queue.go (4)
  • 6-8: The addition of math/big, sync, and time packages supports the new functionality for handling transactions with big.Int chain IDs and concurrent processing.
  • 64-66: Fetching distinct chain IDs for pending transactions using GetChainIDsByStatus is a key improvement. It ensures that transactions are fetched and processed per chain, adhering to intra-chain limits. Proper error handling is observed here, which is crucial for robustness.
  • 69-73: Converting *big.Int chain IDs to int64 for logging purposes is a sensible approach. However, ensure that this conversion does not lead to any loss of information, especially for very large chain IDs that might exceed the int64 range.
  • 77-93: The concurrent processing of transactions per chain ID is a significant enhancement. It leverages goroutines for parallel processing, which can improve the efficiency of transaction processing. Ensure that the sync.WaitGroup is correctly used to wait for all goroutines to complete.
ethergo/submitter/db_test.go (1)
  • 163-207: The addition of TestGetChainIDsByStatus is crucial for verifying the new functionality. It appears to adequately test the retrieval of chain IDs by status, ensuring that the implementation behaves as expected. Consider adding more test cases to cover edge cases, such as no transactions matching the status or transactions across a wide range of chain IDs.
ethergo/submitter/db/mocks/service.go (1)
  • 65-93: The addition of the mock function GetChainIDsByStatus is essential for unit testing components that depend on the Service interface. It correctly mirrors the signature of the actual method, allowing for effective mocking of behavior in tests. Ensure that tests utilizing this mock properly simulate various return scenarios to cover different edge cases.
ethergo/submitter/db/txdb/store.go (2)
  • 8-8: The addition of the math/big package is necessary for handling chain IDs as *big.Int, aligning with the changes made in this PR.
  • 357-383: The implementation of GetChainIDsByStatus in store.go is a key part of this PR's objective to fetch transactions with awareness of individual chains. This method's implementation seems to correctly fetch distinct chain IDs for a given address and status. Ensure that the method is thoroughly tested, especially for cases with a large number of transactions and chain IDs.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 97c0e6f and 49fa679.
Files selected for processing (1)
  • ethergo/submitter/db/service.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ethergo/submitter/db/service.go

Copy link

codecov bot commented Mar 27, 2024

Codecov Report

Attention: Patch coverage is 61.90476% with 8 lines in your changes are missing coverage. Please review.

Project coverage is 46.89678%. Comparing base (490d295) to head (cbe85ea).
Report is 11 commits behind head on master.

Files Patch % Lines
ethergo/submitter/queue.go 61.90476% 7 Missing and 1 partial ⚠️
Additional details and impacted files
@@                 Coverage Diff                 @@
##              master       #2376         +/-   ##
===================================================
+ Coverage   46.89341%   46.89678%   +0.00336%     
===================================================
  Files            399         399                 
  Lines          30548       30565         +17     
  Branches          83          83                 
===================================================
+ Hits           14325       14334          +9     
- Misses         14695       14701          +6     
- Partials        1528        1530          +2     
Flag Coverage Δ
cctp-relayer 43.41463% <ø> (ø)
committee 62.76446% <ø> (-1.20717%) ⬇️
ethergo 60.24119% <61.90476%> (-0.07125%) ⬇️
explorer 24.80122% <ø> (ø)
omnirpc 53.23194% <ø> (ø)
promexporter 75.91241% <ø> (ø)
rfq 29.09708% <ø> (ø)
scribe 52.21130% <ø> (+0.18426%) ⬆️
sin-executor 64.17910% <ø> (+2.23880%) ⬆️
stiprelayer 3.33333% <ø> (ø)
tools 21.98661% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 49fa679 and cbe85ea.
Files selected for processing (1)
  • ethergo/submitter/db/txdb/store.go (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • ethergo/submitter/db/txdb/store.go

@dwasse dwasse merged commit 6e47707 into master Mar 29, 2024
61 of 62 checks passed
@dwasse dwasse deleted the feat/submitter-bump-fairness branch March 29, 2024 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code size/s
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant